﻿namespace Falcon.Forums.Domain
{
	using Falcon.Core.Domain;

	public class ForumTopicTag : EntityBase<ForumTopicTag>
	{
		// private fields
		private ForumTopic _topic;

		/// <summary>
		/// Gets or sets the topic id.
		/// </summary>
		/// <value>The topic id.</value>
		public virtual int TopicId
		{
			get; 
			set;
		}

		/// <summary>
		/// Gets or sets the slug.
		/// </summary>
		/// <value>The slug.</value>
		public virtual string Slug
		{
			get; 
			set;
		}

		/// <summary>
		/// Gets or sets the topic.
		/// </summary>
		/// <value>The topic.</value>
		public virtual ForumTopic Topic
		{
			get
			{
				return _topic;
			}
			set
			{
				_topic = value;

				if (_topic != null)
				{
					this.TopicId = _topic.Id;
				}
			}
		}

		/// <summary>
		/// Validates this instance.
		/// </summary>
		public override void Validate()
		{
			this.Rules().Validate(this);
		}
	}
}